import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DocumentUploadVO, DocumentUploadForm, DocumentUploadQuery } from '@/api/commission/documentUpload/types';

/**
 * 查询上传与下载附件列表
 * @param query
 * @returns {*}
 */

export const listDocumentUpload = (query?: DocumentUploadQuery): AxiosPromise<DocumentUploadVO[]> => {
  return request({
    url: '/commission/documentUpload/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询上传与下载附件详细
 * @param id
 */
export const getDocumentUpload = (id: string | number): AxiosPromise<DocumentUploadVO> => {
  return request({
    url: '/commission/documentUpload/' + id,
    method: 'get'
  });
};

/**
 * 新增上传附件
 * @param data
 */
export const addDocumentUpload = (id: string | number | Array<string | number>) => {
  return request({
    url: '/commission/documentUpload/'+id,
    method: 'post',
  });
};

/**
 * 修改上传与下载附件
 * @param data
 */
export const updateDocumentUpload = (data: DocumentUploadForm) => {
  return request({
    url: '/commission/documentUpload',
    method: 'put',
    data: data
  });
};

/**
 * 删除上传与下载附件
 * @param id
 */
export const delDocumentUpload = (id: string | number | Array<string | number>) => {
  return request({
    url: '/commission/documentUpload/' + id,
    method: 'delete'
  });
};

/**
 * 添加下载数
 * @param id
 */
export const addDownloads = (id: string | number | Array<string | number>) => {
  return request({
    url: '/commission/documentUpload/addDownloads/' + id,
    method: 'get'
  });
};
